package com.itany.corejava.day04;

import java.util.Arrays;

/*
    动态数组

    java中没有动态数组
    实际动态数组相当于数组的拷贝
    扩展的是
    改变变量的引用
 */
public class Test10 {

    public static void main(String[] args) {

        char[] c={'a','b'};

        System.out.println(c.length);//2


        System.out.println(c[0]);
        System.out.println(c[1]);
        System.out.println("Arrays.toString(c) = " + Arrays.toString(c));


        char[] temp=new char[c.length+1];

        // for (int i = 0; i < c.length; i++) {
        //     temp[i]=c[i];
        // }
        System.arraycopy(c,0,temp,0,c.length);

        c=temp;

        c[2]='c';

        System.out.println(c[2]);
        System.out.println(c.length);//3

        System.out.println("Arrays.toString(c) = " + Arrays.toString(c));


    }

}
